%%
%% This is file ntj.cls' version 1.1.
%% Maintainer: Ekasit Kijsipongse
%% Date: Aug 20, 2009
%% 

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{ntj}[2009/07/23 NECTEC Journal LaTeX document class]

%
% Declare and process the options
%
%\DeclareOption{draft}{\PassOptionsToClass{draft}{article}}
\DeclareOption{fleqn}{\PassOptionsToClass{fleqn}{article}}
%\DeclareOption{final}{\PassOptionsToClass{final}{article}}
%\DeclareOption{twocolumn}{\PassOptionsToClass{twocolumn}{article}}
\DeclareOption{twoside}{\PassOptionsToClass{twoside}{article}}
%\DeclareOption{preprint}{\preprinttrue}
%\DeclareOption{a4paper}{\PassOptionsToClass{a4paper}{article}}


\ExecuteOptions{10pt,twocolumn,a4paper,final}
\ProcessOptions

%
% This class simply modifies a few behaviors of the article class,
% so load it now
%
\LoadClass{article}
\setlength{\textheight}{9.275in}
\setlength{\textwidth}{6.675in}
\setlength{\columnsep}{0.3125in}
\setlength{\topmargin}{0in}
\setlength{\headheight}{0in}
\setlength{\headsep}{0.5in}
%\setlength{\parindent}{1pc}
\setlength{\parindent}{0in}
\setlength{\oddsidemargin}{-.2in}
\setlength{\evensidemargin}{-.2in}
\setlength{\parskip}{0.15in plus4mm minus2mm}

\def\@maketitle{%
  \newpage
  \null
  %\vskip 2em%
  \begin{center}%
  \let \footnote \thanks
    %{\Large \bf \@title \par}% Bold 14 points
    {\fontsize{16}{18pt} \selectfont \bf \@title \par}% Bold 16 points 
    \vskip 1.5em%
    {\large
     \it % italic 12 points
      \lineskip .5em%
      \begin{tabular}[t]{c}%
        \@author
      \end{tabular}\par}%
    \vskip 1em%
    %{\large \@date}%
  \end{center}%
  \par
  %\vskip 1.5em
  }

\renewcommand\abstractname{ABSTRACT\ --}
\renewenvironment{abstract}{%
      \thispagestyle{myheadings}
      \fontsize{11pt}{12pt} \selectfont
      \if@twocolumn
         \rule{\textwidth}{.5pt}  % horizontal rule before abstract      
         \vskip 0.8em%
         {\bfseries \Large \abstractname }
      \else
        %\begin{center}%
          {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
        %\end{center}%
        \quotation
      \fi}
      {\newline 
       {\par}
       \if@twocolumn
       \else
         \endquotation
       \fi}
       


\newcommand\keywordsname{KEY WORDS\ --}
\newcommand{\keywords}[1]{{\bfseries \Large \keywordsname} \fontsize{11pt}{12pt} \selectfont #1 \newline \rule{\textwidth}{0.5pt} \newline }
%\newenvironment{keywords}{%
%      \if@twocolumn
%         {\bfseries \keywordsname }
%      \else
%        \small
%          {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
%        \quotation
%      \fi}
%      {\if@twocolumn
%         \newline
%         \rule{\textwidth}{.5pt}  % horizontal rule after abstract
%       \else
%         \endquotation
%       \fi
%      }

\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \it   % italic font in caption
  \sbox\@tempboxa{#1. #2}%
  \ifdim \wd\@tempboxa >\hsize
    \begin{center} % make caption centered
    #1. #2 \par
    \end{center}
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}
  
%Modification of LATEX.LTX's \@sect to put a period after a section number
%(but not after a subsection number).  [The modification is in lines 4--7.]
\def\@sect#1#2#3#4#5#6[#7]#8{%
     \ifnum #2>\c@secnumdepth\let\@svsec\@empty%
     \else
        \ifnum #2=\@ne\refstepcounter{#1}%
           \protected@edef\@svsec{\csname the#1\endcsname.\hskip 1em }
        \else\refstepcounter{#1}%
           \protected@edef\@svsec{\csname the#1\endcsname\hskip 1em }\fi
     \fi
     \@tempskipa #5\relax
      \ifdim \@tempskipa>\z@
        \begingroup #6\relax
          \@hangfrom{\hskip #3\relax\@svsec}%
                    {\interlinepenalty \@M #8\par}%
        \endgroup
       \csname #1mark\endcsname{#7}\addcontentsline
         {toc}{#1}{\ifnum #2>\c@secnumdepth \else
                      \protect\numberline{\csname the#1\endcsname}\fi
                    #7}\else
        \def\@svsechd{#6\hskip #3\relax  %% \relax added 2 May 90
                   \@svsec #8\csname #1mark\endcsname
                      {#7}\addcontentsline
                           {toc}{#1}{\ifnum #2>\c@secnumdepth \else
                           \protect\numberline{\csname the#1\endcsname}%
                                     \fi
                       #7}}\fi
     \@xsect{#5}}

%\RequirePackage{fancyhdr}  % needs fancyhdr package installed 
%\pagestyle{fancy}
%\rhead{\thepage}
%\renewcommand{\headrulewidth}{0pt}
%\newcommand{\markleft}{\lhead}

\pagestyle{myheadings}
\newcommand{\markheader}[1]{\markboth{\normalfont #1}{\normalfont #1}}

\newcommand{\columnspan}[1]{\twocolumn[#1] \saythanks}

\providecommand{\appendiargdef}[2]{\begingroup
  \toks@\expandafter{#1{##1}#2}%
  \edef\@bsx{\endgroup \def\noexpand#1####1{\the\toks@}}%
  \@bsx}

\appendiargdef{\thanks}{%  footnote for affiliation
  \protected@xdef\@bs@thanks{\@bs@thanks
    \protect\footnotetext[\the\c@footnote]{#1}}%
}
\let\@bs@thanks\@empty

\newcommand{\saythanks}{\begingroup   % \thanks needs this before the first section
  \renewcommand{\thefootnote}{\fnsymbol{footnote}}\@bs@thanks
  \endgroup\global\let\@bs@thanks\@empty}

\newcommand{\authormark}{\thanks}

% \@startsection {NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE} 
%            optional * [ALTHEADING]{HEADING}
%    Generic command to start a section.  
%    NAME       : e.g., 'subsection'
%    LEVEL      : a number, denoting depth of section -- e.g., chapter=1,
%                 section = 2, etc.  A section number will be printed if
%                 and only if LEVEL < or = the value of the secnumdepth
%                 counter.
%    INDENT     : Indentation of heading from left margin
%    BEFORESKIP : Absolute value = skip to leave above the heading.  
%                 If negative, then paragraph indent of text following 
%                 heading is suppressed.
%    AFTERSKIP  : if positive, then skip to leave below heading,
%                       else - skip to leave to right of run-in heading.
%    STYLE      : commands to set style
%  If '*' missing, then increments the counter.  If it is present, then
%  there should be no [ALTHEADING] argument.  A sectioning command
%  is normally defined to \@startsection + its first six arguments.
     
\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {0.1ex \@plus .1ex}%
                                   {\normalfont\Large\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {0.1ex \@plus .1ex}%
                                     {\normalfont\large\bfseries}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {0.1ex \@plus .1ex}%
                                     {\normalfont\normalsize\bfseries}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                    {-3.25ex \@plus -1ex \@minus -.2ex}%
                                    {-1em}%
                                    {\normalfont\normalsize\bfseries}}  
\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
                                       {-3.25ex \@plus -1ex \@minus -.2ex}%
                                       {-1em}%
                                      {\normalfont\normalsize\bfseries}}                                                                       

